package com.hzlx.productionProducts.feign.RollBack;


import com.hzlx.BomComponentsDto;
import com.hzlx.BomsDto;
import com.hzlx.MesBadGoodsDto;
import com.hzlx.ResultDto;
import com.hzlx.productionProducts.feign.baseDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

@Component
public class baseDataServiceFallbackFactory implements FallbackFactory<baseDataService> {
    private static final Logger logger = LoggerFactory.getLogger(baseDataServiceFallbackFactory.class);
    @Override
    public baseDataService create(Throwable cause) {
        return new baseDataService() {
            @Override
            public List<BomsDto> list(BomsDto boms) {
                logger.error("base-data-service list接口调用失败，参数: {}, 异常: {}", boms, cause.getMessage(), cause);
                // 根据业务需求返回合理默认值
                throw new RuntimeException("BOM列表查询失败: " + cause.getMessage());
            }

            @Override
            public List<BomComponentsDto> BomComponentsList(BomComponentsDto bomComponents) {
                logger.error("base-data-service BomComponentsList接口调用失败，参数: {}, 异常: {}",
                        bomComponents, cause.getMessage(), cause);

                // 根据业务需求返回合理默认值
                throw new RuntimeException("BOM组件查询失败: " + cause.getMessage());
            }
        };
    }
}
